import { HOSTNAME, SUPPORTED_PLATFORMS } from '../../../../../types/constants'
import { IPaginationLoadType } from '../index'
import { AutoPaginationBase } from './base'

export enum GithubSearchParams {
  After = 'after',
}
export interface IGithubUrlParams {
  [GithubSearchParams.After]: string
}

export class AutoPaginationGithub extends AutoPaginationBase {
  // @Decorators.Identity
  readonly name: string = 'AutoPaginationGithub'
  // @Decorators.PublicState
  private static instance: AutoPaginationGithub
  // @Decorators.Config
  readonly loadType: IPaginationLoadType = IPaginationLoadType.Pagination
  readonly defaultUrlParams: IGithubUrlParams = { // 搜索链接默认参数值
    [GithubSearchParams.After]: '1.0.0',
  }

  /**
   * 获取单例实例
   */
  public static getInstance(): AutoPaginationGithub {
    if (!AutoPaginationGithub.instance) {
      AutoPaginationGithub.instance = new AutoPaginationGithub()
    }
    return AutoPaginationGithub.instance
  }

  /**
   * 检查页面
   */
  checkPage(): boolean {
    return HOSTNAME === SUPPORTED_PLATFORMS.GITHUB
  }
}
